#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
    int l, m;
    scanf("%d%d", &l, &m);
    getchar();

    int tree[10001] = { 0 };
    while (m--)
    {
        int left, right;
        scanf("%d%d", &left, &right);
        for (int i = left; i <= right; i++)
            tree[i] = 1;
    }
    int remain = l + 1;
    for (int i = 0; i <= l; i++)
    {
        if (tree[i] == 1)
            remain--;
    }
    printf("%d", remain);
    return 0;
}